﻿<%@ WebHandler Language="C#" Class="DepartmentList" %>

using System;
using System.Web;
using System.Text;
using System.Collections.Generic;
using Chenxin.Lib.Utility;
using System.Data;

public class DepartmentList : AjaxHandlerBase
{
    public DepartmentList()
    {
        htTypePermit.Add("edit", Constants.Permit_DepartSettingEdit);
    }

    override public void RequestProcess(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Buffer = true;
        context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";

        //处理类型
        string op = context.Request.Params["op"];
        
        string strResult = "";
        
        switch (op)
        {
            case "show":        //得到查询列表
                strResult=ShowData(context);
                break;
            case "GetSettingInfo":      //得到部门参数数据
                strResult = GetSettingInfo(context);
                break;
            case "edit":        //修改部门参数
                strResult = EditSetting(context);
                break;
            case "getlist":
                strResult = GetList(context);
                break;
        }
        context.Response.Write(strResult);
    }

    private string GetList(HttpContext context)
    {

        string selCity = context.Request.Params["cityid"];
        string selCompany = context.Request.Params["companyid"];
        string selDepartType = context.Request.Params["divType"];
        string selBusiness = context.Request.Params["areaid"];


        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        if (selBusiness != "" && selBusiness != "请选择" && selBusiness != null)
        {
            Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo item = null;
            string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, selBusiness);
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            item = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
            if (!cs.Hit)
            {
                item = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(new Guid(selBusiness));
                if (item != null) cs.Set(strCachkey, item, DateTime.Now.AddDays(1));
            }

            if (item == null) return string.Format("{{success:'0',msg:'{0}',data:''}}", "获取商圈或分类数据丢失");

            sb.AppendFormat(" AND (DepartId in (select departId from Hr_DepartmentInfo where DepartSrc like '{0}%'))", item.DepartSrc);
        }
        else if (selCompany != "" && selCompany != "请选择" && selCompany != null)
            sb.AppendFormat(" AND CompanyId = '{0}'", selCompany);
        else if (selCity != "" && selCity != "请选择" && selCity != null)
            sb.AppendFormat(" AND CityId = '{0}'", selCity);


        System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
        //查看权限
        //所有
        if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewAllDepartSetting))
        {
            sb1.Append(" (1=1) ");
        }
        //城市
        else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewCityDepartSetting))
        {
            sb1.Append(string.Format("  CityId = '{0}' ", CurrentUserInfo.CityId.ToString()));
        }
        //公司
        else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewCompanyDepartSetting))
        {
            sb1.Append(string.Format("  CompanyId = '{0}' ", CurrentUserInfo.CompanyId.ToString()));
        }
        //部门
        //else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewDepartDepartSetting))
        //{
        //    sb1.Append(" EXISTS(");
        //    sb1.Append(string.Format("Select 1 from Struct_UserDepartRelation M WHERE Hr_DepartmentInfo.DepartId=M.DepartId And M.Userid= '{0}'", CurrentUserInfo.UserId.ToString()));
        //    sb1.Append(") ");
        //}
        //没有权限
        else
        {
            sb1.Append(string.Format(" (1=0) ", CurrentUserInfo.UserId.ToString()));
        }

        if (!String.IsNullOrEmpty(sb.ToString()))
            sb1.Append(sb.ToString());
        if (selDepartType != "" && selDepartType != "请选择" && selDepartType != null)
        {
            sb1.Append("and DepartKind='" + selDepartType + "'");
        }

        sb1.Append(" and  (DepartProperty=500 or DepartProperty=600) ");

        int PageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;//页码
        int PageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30 : int.Parse(context.Request["pagesize"]);//页记录数


        DataSet ds = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetList(PageIndex, PageSize, "dbo.Hr_DepartmentInfo.DepartName ", "dbo.Hr_DepartmentInfo", sb1.ToString(), "*,Bussiness,UserCount", "*,dbo.FN_GetBussinessByDepartID(DepartId) as Bussiness,dbo.FN_GetUserCountByDepartID(DepartId) as UserCount", true);
        int count = (int)ds.Tables[1].Rows[0][0];
        
        
        
        
        string strHtml = "";
        if (!GetKeyListHtml(ds, out strHtml))
        {
            return string.Format("{{success:'0',msg:'{0}',data:''}}", "生成HTML错误:" + strHtml);
        }
        return string.Format("{{success:1,msg:'{0}',data:{{count:{1},{2}}}}}", "成功", count, JsonHelp.Convert2Json(ds.Tables[0]));
    }

    //修改部门参数
    private string EditSetting(HttpContext context)
    {
        try
        {
            string ViewOwnerNum = "",
                     IsHideHouse = "",
                     IsAloneUserCode = "",
                     ProtectedNum = "",
                     IsProtectMark = "",
                     AllowPrivHouse = "",
                     MarkProtectHours = "",
                     AllowPubDemand = "",
                     IsUseBlacklist = "",
                     Level = "",
                     LockHouseDay = "",
            CanAddAtCityId = "",
            CanAddAtCityName = "",
            CustomerDemandNum="",
            OverTimeTraceNum="",
            IsTelRepeat="",
            DepartId = "",
            depsql="";
            

            if (!string.IsNullOrEmpty(context.Request.Params["DepartId"]))
            {
                DepartId = context.Request.Params["DepartId"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["ViewOwnerNum"]))
            {
                ViewOwnerNum = context.Request.Params["ViewOwnerNum"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["IsHideHouse"]))
            {                
                IsHideHouse = context.Request.Params["IsHideHouse"];
            }
            else
                IsHideHouse = "0";
            if (!string.IsNullOrEmpty(context.Request.Params["IsAloneUserCode"]))
            {
                IsAloneUserCode = context.Request.Params["IsAloneUserCode"];
            }
            else
                IsAloneUserCode = "0";
            if (!string.IsNullOrEmpty(context.Request.Params["ProtectedNum"]))
            {
                ProtectedNum = context.Request.Params["ProtectedNum"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["IsProtectMark"]))
            {
                IsProtectMark = context.Request.Params["IsProtectMark"];
            }
            else
                IsProtectMark = "0";
            if (!string.IsNullOrEmpty(context.Request.Params["AllowPrivHouse"]))
            {
                AllowPrivHouse = context.Request.Params["AllowPrivHouse"];
            }
            else
                AllowPrivHouse = "0";
            if (!string.IsNullOrEmpty(context.Request.Params["MarkProtectHours"]))
            {
                MarkProtectHours = context.Request.Params["MarkProtectHours"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["AllowPubDemand"]))
            {
                AllowPubDemand = context.Request.Params["AllowPubDemand"];
            }
            else
                AllowPubDemand = "0";
            if (!string.IsNullOrEmpty(context.Request.Params["IsUseBlacklist"]))
            {
                IsUseBlacklist = context.Request.Params["IsUseBlacklist"];
            }
            else
                IsUseBlacklist = "0";
            if (!string.IsNullOrEmpty(context.Request.Params["BlacklistLevel"]))
            {
                Level = context.Request.Params["BlacklistLevel"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["LockHouseDay"]))
            {
                LockHouseDay = context.Request.Params["LockHouseDay"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["CanAddAtCityId"]))
            {
                CanAddAtCityId = context.Request.Params["CanAddAtCityId"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["CanAddAtCityName"]))
            {
                CanAddAtCityName = context.Request.Params["CanAddAtCityName"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["CustomerDemandNum"]))
            {
                CustomerDemandNum = context.Request.Params["CustomerDemandNum"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["OverTimeTraceNum"]))
            {
                OverTimeTraceNum = context.Request.Params["OverTimeTraceNum"];
            }
            if (!string.IsNullOrEmpty(context.Request.Params["IsTelRepeat"]))
            {
                IsTelRepeat = context.Request.Params["IsTelRepeat"];
            }
            else
                IsTelRepeat = "0";
            
            
            //部门基本数值
            if (!string.IsNullOrEmpty(context.Request.Params["IsOpen"]))
                depsql += "IsOpen=1,";
            else
                depsql += "IsOpen=0,";
            if (!string.IsNullOrEmpty(context.Request.Params["IsCalculate"]))
                depsql += "IsCalculate=1,";
            else
                depsql += "IsCalculate=0,";
            if(!string.IsNullOrEmpty(context.Request.Params["IsContractCenter"]))
                depsql += "IsContractCenter=1,";
            else
                depsql += "IsContractCenter=0,";
            if (!string.IsNullOrEmpty(context.Request.Params["IsRoof"]))
                depsql += "IsRoof=1,";
            else
                depsql += "IsRoof=0,";
            if (!string.IsNullOrEmpty(context.Request.Params["RegionCtr"]) && context.Request.Params["RegionCtr"] != "undefined")
                depsql += "RegionCtr='" + context.Request.Params["RegionCtr"] + "',";
            else
                depsql += "RegionCtr='',";

            string Area = context.Request.Params["Area"];
            
            string strSql = @"update House_BusinessSetting set ProtectedNum='" + ProtectedNum + "',ViewOwnerNum='" + ViewOwnerNum + "',IsHideHouse='" + IsHideHouse + "',IsAloneUserCode='" + IsAloneUserCode + "',LockHouseDay='" + LockHouseDay + "',IsProtectMark='" + IsProtectMark + "',MarkProtectHours='" + MarkProtectHours + "',AllowPrivHouse='" + AllowPrivHouse + "',AllowPubDemand='" + AllowPubDemand + "',IsUseBlacklist='" + IsUseBlacklist + "',BlacklistLevel='" + Level + "',CanAddAtCityId='" + CanAddAtCityId + "',CanAddAtCityName='" + CanAddAtCityName + "',CustomerDemandNum='" + CustomerDemandNum + "',OverTimeTraceNum='" + OverTimeTraceNum + "',IsTelRepeat='" + IsTelRepeat + "' where DepartId='" + DepartId + "'; ";

            Chenxin.Lib.House.DAL.House_BaseInfo.ExecuteSQL(strSql);

            //删除部门参数缓存
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            string strCacheKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPART_SETTINGS, DepartId);
            cs.Delete(strCacheKey);

            strSql = "update Hr_DepartmentInfo set " + depsql.Substring(0, depsql.Length - 1) + " where DepartId='" + DepartId + "'";
            Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.ExecuteSQL(strSql);
            
            strCacheKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, DepartId);
            cs.Delete(strCacheKey);
            
            //片区设定
            if (!string.IsNullOrEmpty(Area))
            {
                Chenxin.Lib.House.BLL.BlockSetting bllbs = new Chenxin.Lib.House.BLL.BlockSetting();
                bllbs.DelBlockByDepartId(new Guid(DepartId));
                bllbs.AddBlock(new Guid(DepartId), Area);
            }
            
            //添加用户操作日志 2010-5-12 王玮 Add
            AddLog("" + CurrentUserInfo.UserName + "编辑了一个部门参数",
                    OperationType.OperationTypeComboList()["OprType_DepSettingEdit"].ToString()); 
            
            return "{success:'1',msg:'提交成功',data:''}";
        }
        catch (Exception ex)
        {
            return "{success:'0',msg:'"+ex.Message+"',data:''}";
        }
    }
    
    //根据部门ID得到部门的参数
    private string GetSettingInfo(HttpContext context)
    {
        string DepartId = context.Request.Params["DepId"];
        StringBuilder strb = new StringBuilder();

        string strKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPART_SETTINGS, DepartId);
        Chenxin.Lib.House.Entity.House_BusinessSetting ds;
        Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo hr_dep;
        try
        {
            //获取部门参数信息
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            ds = cs.GetObject(strKey) as Chenxin.Lib.House.Entity.House_BusinessSetting;
            if (!cs.Hit)
            {
                ds = Chenxin.Lib.House.DAL.House_BusinessSetting.GetModel(new Guid(DepartId));
                if (ds != null) cs.Set(strKey, ds);
            }
            if (ds == null)
            {
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "参数错误，找不到对应的部门参数");
            }
            
            //获取部门基本信息
            strKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, DepartId);
            hr_dep = cs.GetObject(strKey) as Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo;
            if (!cs.Hit) 
            {
                hr_dep = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(new Guid(DepartId));
                if (hr_dep != null) cs.Set(strKey, hr_dep);
            }
            
            //获取片区
            Chenxin.Lib.House.BLL.BlockSetting bllbs = new Chenxin.Lib.House.BLL.BlockSetting();
            string strblock = bllbs.GetBlockByDepartId(new Guid(DepartId));

            //判断是否使用片区规则
            string needArea = bllbs.CheckBlockRole(hr_dep.CompanyId);
            
            return string.Format("{{success:'1',msg:'成功',data:{{setting:{0},IsOpen:'{1}',IsCalculate:'{2}',RegionCtr:'{3}',IsContractCenter:'{4}',IsRoof:'{5}',CityId:'{6}',Area:'{7}',needArea:{8}}}}}",
                Chenxin.Lib.Utility.JsonHelp.Convert2Json(ds), hr_dep.IsOpen, hr_dep.IsCalculate, hr_dep.RegionCtr, hr_dep.IsContractCenter, hr_dep.IsRoof, hr_dep.CityId, strblock, needArea);
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'{0}',data:''}}", ex.Message);
        }          
    }

    //根据查询条件，显示部门列表
    private string ShowData(HttpContext context)
    {
        string selCity = context.Request.Params["cityid"];
        string selCompany = context.Request.Params["companyid"];
        string selDepartType = context.Request.Params["divType"];
        string selBusiness = context.Request.Params["areaid"];


        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        if (selBusiness != "" && selBusiness != "请选择" && selBusiness != null)
        {
            Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo item = null;
            string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, selBusiness);
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            item = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
            if (!cs.Hit)
            {
                item = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(new Guid(selBusiness));
                if (item != null) cs.Set(strCachkey, item, DateTime.Now.AddDays(1));
            }

            if (item == null) return string.Format("{{success:'0',msg:'{0}',data:''}}", "获取商圈或分类数据丢失");

            sb.AppendFormat(" AND (DepartId in (select departId from Hr_DepartmentInfo where DepartSrc like '{0}%'))", item.DepartSrc);
        }
        else if (selCompany != "" && selCompany != "请选择" && selCompany != null)
            sb.AppendFormat(" AND CompanyId = '{0}'", selCompany);
        else if (selCity != "" && selCity != "请选择" && selCity != null)
            sb.AppendFormat(" AND CityId = '{0}'", selCity);


        System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
        //查看权限
        //所有
        if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewAllDepartSetting))
        {
            sb1.Append(" (1=1) ");
        }
        //城市
        else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewCityDepartSetting))
        {
            sb1.Append(string.Format("  CityId = '{0}' ", CurrentUserInfo.CityId.ToString()));
        }
        //公司
        else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewCompanyDepartSetting))
        {
            sb1.Append(string.Format("  CompanyId = '{0}' ", CurrentUserInfo.CompanyId.ToString()));
        }
        //部门
        //else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewDepartDepartSetting))
        //{
        //    sb1.Append(" EXISTS(");
        //    sb1.Append(string.Format("Select 1 from Struct_UserDepartRelation M WHERE Hr_DepartmentInfo.DepartId=M.DepartId And M.Userid= '{0}'", CurrentUserInfo.UserId.ToString()));
        //    sb1.Append(") ");
        //}
        //没有权限
        else
        {
            sb1.Append(string.Format(" (1=0) ", CurrentUserInfo.UserId.ToString()));
        }

        if (!String.IsNullOrEmpty(sb.ToString()))
            sb1.Append(sb.ToString());
        if (selDepartType != "" && selDepartType != "请选择" && selDepartType != null)
        {
            sb1.Append("and DepartKind='" + selDepartType + "'");
        }
        
        sb1.Append(" and  (DepartProperty=500 or DepartProperty=600) ");
        
        int PageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;//页码
        int PageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30 : int.Parse(context.Request["pagesize"]);//页记录数


        DataSet ds = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetList(PageIndex, PageSize, "dbo.Hr_DepartmentInfo.DepartName ", "dbo.Hr_DepartmentInfo", sb1.ToString(), "*,Bussiness,UserCount", "*,dbo.FN_GetBussinessByDepartID(DepartId) as Bussiness,dbo.FN_GetUserCountByDepartID(DepartId) as UserCount", true);
        int count = (int)ds.Tables[1].Rows[0][0];
        string strHtml = "";
        if (!GetKeyListHtml(ds, out strHtml))
        {
            return string.Format("{{success:'0',msg:'{0}',data:''}}", "生成HTML错误:" + strHtml);
        }
        ds.Dispose();
        ds = null;
        return string.Format("{{success:'1',msg:'{0}',data:{{count:'{1}',data:'{2}'}}}}", "成功", count, strHtml);
    }

    //生成部门列表的HTML
    private bool GetKeyListHtml(DataSet dslist, out string strHtml)
    {
        try
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<table width=\"100%\" height=\"100%\" cellspacing=\"1\" class=\"tabsorternew\" id=\"report\">");
            sb.Append("<thead><tr>");
            sb.Append("<th width=\"8%\">部门编号</th>");
            sb.Append("<th width=\"8%\">名称</th>");
            sb.Append("<th width=\"5%\" >城市</th>");
            sb.Append("<th width=\"8%\" >所属公司</th>");
            sb.Append("<th width=\"7%\">类别</th>");
            sb.Append("<th width=\"8%\">电话</th>");
            sb.Append("<th width=\"10%\">地址</th>");
            sb.Append("<th width=\"10%\">Email</th>");
            sb.Append("<th width=\"5%\">开通</th>");
            sb.Append("<th width=\"5%\">统计</th>");
            sb.Append("<th width=\"8%\">区域</th>");
            sb.Append("<th width=\"8%\">商圈</th>");
            sb.Append("<th width=\"10%\">人数</th>");
            sb.Append("</tr></thead><tbody>");

            foreach (DataRow row in dslist.Tables[0].Rows)
            {
                sb.AppendFormat("<tr id=\"{0}\" class=\"tr_houselist\" ondblclick=\"{1}\" >", row["DepartId"].ToString(), "ShowDetal(this.id);");
                sb.AppendFormat("<td>{0}{1}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "DepartCode", ""), "<input type=\"hidden\" id=\"hdn" + row["DepartId"].ToString() + "\" value=\"" + Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "DetalInfo", "") + "\" />");
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "DepartName", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "City", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CompanyName", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "DepartKind", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Tel", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Address", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Email", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsOpen", "") == "True" ? "是" : "否");
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "IsCalculate", "") == "True" ? "是" : "否");

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Region", ""));

                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Bussiness", ""));
                sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "UserCount", ""));
                sb.Append("</tr>");
            }

            sb.Append("</tbody></table>");
            strHtml = sb.ToString();
            return true;
        }
        catch (Exception ex)
        {
            strHtml = ex.Message;
            return false;
        }
    }

}